USE [NANS21V]
GO

/****** オブジェクト: SqlProcedure [dbo].[Entry] スクリプト日付: 2014/07/14 11:09:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Entry]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Entry]
GO

CREATE PROCEDURE [dbo].[Entry]
	@TAIKAINO int,
	@KYOGISYANO int
AS
SELECT 
	K.KYOGINO, 
	K.KYOGIMEI,
	(CASE WHEN 0 = 8 THEN LEFT(SK.KIROKU,(charindex('.', SK.KIROKU)-1)) ELSE 
	dbo.Kiroku(SK.KIROKU,SM.SYUMOKUKUBUN,SM.KIROKUKUBUN,SK.KIROKUFLG) END) AS KIROKU, 
	SK.OPENFLG, 
	SK.KIROKUFLG 
FROM 
	TBL_SANKAKYOGI AS SK, 
	TBL_KYOGI AS K ,
	TBL_SYUMOKU_MASTER AS SM
WHERE 
	SK.TAIKAINO = @TAIKAINO 
	AND SK.KYOGISYANO = @KYOGISYANO
	AND SK.TAIKAINO = K.TAIKAINO 
	AND SK.KYOGINO = K.KYOGINO 
	AND K.GATTAIFLG <> 2
	AND K.SYUMOKUNO = SM.SYUMOKUNO --0508add 
